#!/usr/bin/env bash

set -euvo pipefail

# Creates Basic Authentication Context
pushd tests/functional/artifacts/registry/

echo "Generating Local Docker Registry Artifacts at $(pwd)"
mkdir -p auth certs

docker run --rm --entrypoint htpasswd registry:2.7.0 -Bbn "$ANCHORE_TEST_DOCKER_REGISTRY_USER" "$ANCHORE_TEST_DOCKER_REGISTRY_PASS" > ./auth/htpasswd
openssl req -newkey rsa:4096 -nodes -sha256 -keyout ./certs/domain.key -x509 -days 365 -out ./certs/domain.crt -subj "/C=US/ST=California/L=Santa Barbara/O=Anchore/CN=functional_test"